<?php /*a:1:{s:67:"D:\web\wwwroot\tp5.1\public/../app/admin\view\auth_group\index.html";i:1526183372;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表格</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">

<div><a class="layui-btn site-demo-active layui-btn-sm" href="<?php echo url('admin/AuthGroup/add'); ?>"><i class="layui-icon">&#xe608;</i>添加新角色</a></div>
<table class="layui-table" lay-filter="parse-table-demo" id="test33" style="display:none">
    <thead>
    <tr>
        <th lay-data="{field:'id', width:50, sort: true}">id</th>
        <th lay-data="{field:'title', width:150}">角色</th>
        <th lay-data="{field:'module', width:100}">模块</th>
        <th lay-data="{field:'notation', minwidth:150,edit: 'text'}">描述</th>
        <th lay-data="{field:'status', width:100, templet: '#statusTpl', unresize: true}">状态</th>
        <th lay-data="{fixed: 'right', width:128, align:'center', toolbar: '#barDemo'}">操作</th>
    </tr>
    </thead>
    <tbody>
<?php foreach($list as $key=>$vo): ?>
    <tr>
        <td dat-id="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities($vo['id']); ?></td>
        <td><?php echo htmlentities($vo['title']); ?></td>
        <td><?php echo htmlentities($vo['module']); ?></td>
        <td><?php echo htmlentities($vo['notation']); ?></td>
        <td><?php echo htmlentities($vo['status']); ?></td>
        <td> <a href="<?php echo url('admin/AuthGroup/edit',['id'=>$vo['id']]); ?>">修改</a> | <a href="<?php echo url('admin/AuthGroup/delete',['id'=>$vo['id']]); ?>">删去</a></td>
    </tr>
<?php endforeach; ?>
    </tbody>
</table>

<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>

<script type="text/html" id="statusTpl">
  <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="禁|否" lay-filter="lockstatus" {{ d.status == 0 ? 'checked' : '' }}>
</script>

<script type="text/javascript" src="/static/frame/layui/layui.js"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>
<script type="text/javascript">
layui.use(['form','table'], function(){
  var $ = layui.jquery
      ,form = layui.form
      ,table = layui.table;
        // you code ...
      table.init('parse-table-demo', { //转化静态表格
        height:'full-120',
        page: false, limit:100
      }); 

      //监听单元格编辑
      table.on('edit(parse-table-demo)', function(obj){
        //console.log('d','dss')
        var value = obj.value //得到修改后的值
        ,data = obj.data; //得到所在行所有键值
        $.post('<?php echo url('admin/AuthGroup/quickedit'); ?>',{id:data.id,notation:value},function(data){
            if(data.code == 1){
                layer.tips(data.msg, obj.othis);
            }
        });

      });

  //监听锁定操作
      form.on('switch(lockstatus)', function(obj){
        if(obj.elem.checked === true){
            statusval =0;
        }else{
            statusval =1;
        }
        $.post('<?php echo url('admin/AuthGroup/quickedit'); ?>',{id:this.value,status:statusval},function(data){
            if(data.code == 1){
                layer.tips(data.msg, obj.othis);
            }else{
              layer.tips(data.msg, obj.othis);
            }
        });
    });
      //监听工具条
      table.on('tool(parse-table-demo)', function(obj){
        var data = obj.data;
        if(obj.event === 'del'){
          layer.confirm('真的删除行么', function(index){
            $.get("<?php echo url('admin/AuthGroup/delete'); ?>?id=" + data.id,function(data){
            if (data.code == 1) {
              layer.msg(data.msg);
              obj.del();
              layer.close(index);
            }else{
              layer.msg(data.msg);
              layer.close(index);
            };
            // window.location.href='<?php echo url('delete','',false); ?>/id/'+data.id ;
            // obj.del();
            // layer.close(index);
          });
      })
        } else if(obj.event === 'edit'){
          window.location.href='<?php echo url('admin/AuthGroup/edit'); ?>?id='+data.id ;
          //layer.alert('编辑行：<br>'+ data.id)
        }
      });

});
</script>
</body>
</html>